import '../public.dart';

class MessageApi {
  /// 设置消息已读
  /// /msg/readMsg/{msgId}
  static Future<BaseResponse<void>> readWriteoffMsg() async {
    final response = await HttpUtil().request(
      '/msg/readMsg/{msgId}',
      method: 'POST',
    );
    return BaseResponse<void>.fromJson(response);
  }

  /// 全部已读
  /// /msg/readAll
  static Future<BaseResponse<void>> readAll() async {
    final response = await HttpUtil().request('/msg/readAll', method: 'POST');
    return BaseResponse<void>.fromJson(response);
  }

  /// 分页查询客户端推送消息
  /// /msg/getMsgPage
  static Future<BaseResponse<PagedDataResponse<ClientUserMsgEntity>>>
  getClientUserMsgPage(ClientUserMsgPageRequestDto params) async {
    final response = await HttpUtil().request(
      '/msg/getMsgPage',
      method: 'POST',
      data: params.toJson(),
    );
    return BaseResponse<PagedDataResponse<ClientUserMsgEntity>>.fromJson(
      response,
      fromJsonT: (json) => PagedDataResponse<ClientUserMsgEntity>.fromJson(
        json,
        (json2) => ClientUserMsgEntity.fromJson(json2),
      ),
    );
  }
}
